import axios from 'axios';
import query from 'query-string';

const BASE_URL = '/member/member';


export interface MemberParam {
    username?: string;
    page?: number;
    size?: number;
    sort?: Array<string>;
}

export interface MemberResponse {
    id?: number;
    username: string;
    avatar: string;
    googleKey?: string;
    googleStatus?: number;
    realName?: string;
    email?: string;
    phone?: string;
    gender?: number;
    birthday?: string;
    countryCode?: string;
    country?: string;
    province?: string;
    city?: string;
    district?: string;
    gradeLevel?: string;
    loginCount?: string;
    loginErrorCount?: string;
    lastLogin?: string;
}

export interface MemberResponseList {
    list: MemberResponse[];
    total: number;
}

// 分页获取用户列表
export function pageMember(params: MemberParam) {
    return axios.post<MemberResponseList>(`${BASE_URL}/page/list`, params);
}


// 切换用户状态
export function switchMemberStatus(id: number) {
    return axios.patch(`${BASE_URL}/switch/status/${id}`);
}